﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace Pawn
{
    public partial class FrmPVIn : Form
    {
        public String SoPhieu { get; set; }
        public FrmPVIn()
        {
            InitializeComponent();
            SoPhieu = "P00001";
        }

        private void FrmIn_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dsPhieuVay.DataTable1' table. You can move, or remove it, as needed.
            this.DataTable1TableAdapter.Fill(this.dsPhieuVay.DataTable1,SoPhieu);
            this.reportViewer1.LocalReport.SubreportProcessing +=
                SubreportProcessingEventHandler;
            this.reportViewer1.RefreshReport();
        }
        void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
        {
            DataClassesDataContext db=new DataClassesDataContext();
            dsPhieuVay.DongLaiDataTable dt=new dsPhieuVay.DongLaiDataTable();
            var q= from dl in db.DongLais
                   where dl.SoPC == SoPhieu
                   select dl;
            foreach(var dl in q)
            {
                dt.Rows.Add(dl.NgayDong,dl.Id);
            }
            e.DataSources.Add(new ReportDataSource("dsPhieuVay_LanDong", (DataTable)dt));
        }
    }
}
